import requests


class EmployeeApi(object):
    url = "http://ihrm2-test.itheima.net/api/sys/user"

    @classmethod
    def add_emp(cls, headers, body):
        """
        新增员工
        :param headers: 包含令牌的请求头
        :param body: 新增员工的请求体
        :return: resp 新增员工的响应对象
        """
        resp = requests.post(cls.url, headers=headers, json=body)
        return resp


if __name__ == '__main__':
    token = "Bearer 44f45f20-922c-4eee-a317-7a47d9a7da18"
    headers = {"Authorization": token}
    body = {"username": "zhansan",
            "mobile": "18210000904",
            "workNumber": "10010",
            "timeOfEntry": "2019-11-30",
            "formOfEmployment": "1",
            "departmentId": "1001112",
            "correctionTime": "2020-11-30"}

    data = EmployeeApi.add_emp(headers, body)
    print(data.json())